package org.ssssssss.magicapi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.ssssssss.magicapi.core.config.MagicAPIProperties;
import org.ssssssss.magicapi.core.config.MagicPluginConfiguration;
import org.ssssssss.magicapi.core.model.Plugin;
import org.ssssssss.magicapi.core.service.MagicAPIService;

@Configuration
public class MagicSerialCommConfiguration implements MagicPluginConfiguration {

	private final MagicAPIProperties properties;

	@Autowired
	private MagicAPIService service;
	

	@Value("${magic-api.serialcomm.init-start:false}")
	public boolean initStart;
	@Value("${magic-api.serialComm.name}")
	public String name;
	@Value("${magic-api.serialcomm.protocal}")
	public String protocal;
	
	@Value("${magic-api.serialcomm.monitorApi}")
	public String monitorApi;

	
	public MagicSerialCommConfiguration(MagicAPIProperties properties) {
		this.properties = properties;
	}


	@Override
	public Plugin plugin() {
		System.out.println("串口插件:initStart="+initStart);
		if(service!=null) {			
			try {
				if(initStart) {

				}
				//
			} catch (Exception e) {
				System.out.println("串口监视: ERROR=="+e.getMessage());
				e.printStackTrace();
			}
		}
		else {
			System.out.println("串口监视:@Autowired MagicAPIService ERROR");
		}
		return new Plugin("串口监视:serialComm");
	}
}
